get comments
Retrieve user comments from TabNews content by specifying the username and slug parameters to analyze discussions and feedback.
Instructions
get comments from a content on tabnews api
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| username | Yes | The username to get the content | |
| slug | Yes | The slug to get the content |
Implementation Reference
- src/tools/status.ts:164-186 (handler)The handler function for the 'get comments' tool. It fetches comments using the getContentChildren service and returns a formatted MCP text response with JSON data.handler: async (params: GetContentParams): Promise<McpResponse> => { try { const result = await getContentChildren({ username: params.username, slug: params.slug, }); const content: McpTextContent = { type: "text", text: `Comments:\n\n${JSON.stringify(result, null, 2)}`, }; return { content: [content], }; } catch (error) { if (error instanceof Error) { throw new Error(`Failed to get comments: ${error.message}`); } else { throw new Error("Failed to get comments"); } } },
- src/tools/status.ts:160-163 (schema)Zod schema defining the input parameters for the 'get comments' tool: username and slug.parameters: { username: z.string().describe("The username to get the content"), slug: z.string().describe("The slug to get the content"), },
- src/index.ts:52-57 (registration)Registration of the 'get comments' tool (imported as getContentChildrenTool) with the MCP server using server.tool().server.tool( getContentChildrenTool.name, getContentChildrenTool.description, getContentChildrenTool.parameters, getContentChildrenTool.handler );
- src/services/api.ts:71-81 (helper)Supporting API service function that fetches the comments (children) from the TabNews API endpoint.export async function getContentChildren({ username, slug, }: GetContentParams): Promise<TabNewsContentChildren[]> { const response = await fetch( `${TABNEWS_API_URL}/contents/${username}/${slug}/children` ); const data = await response.json(); return data as TabNewsContentChildren[]; }